define(['angular'], function(angular) {
    angular.module('firefly_bottom_dir',[])
    .directive('fireflyBottom', [function() {
        return {
            restrict: 'AE',
            scope: {
        		isShow: '@menuShow', // 是否显示meun
        		menuType: '@menu'    // 显示menu的type
            },
            templateUrl: "tpls/fireflyBottomShow.html",
            link: function(scope, element, attrs, location) {
            	var list = [{"isSlt":true,"name":"产品中心","type":"home_page","class":"home_page"},
        		            // {"isSlt":false,"name":"风险投","type":"loan","class":"invest"},
        		            // {"isSlt":false,"name":"案源库","type":"case_src_lib","class":"badSource"},
        		            {"isSlt":false,"name":"个人中心","type":"mine","class":"mine"}
        		            ];
        		scope.menuList = list;
        		
        		//监听红点（默认false）
        		scope.$on("mineRedPoint",function(event,data){
        			scope.isshow_block = data;
        		});
        		
        		// 监控指令元素 isShow 属性
                scope.$watch('isShow', function(){
                    if (scope.isShow == 'false') {
                    	scope.menuHide = false;
                    }else{
                    	scope.menuHide = true;
                    }
                });
        		
        		//选择底部按钮
        		scope.selectType = function(type){
        			changeMenuShow(type);
        			if(type == "home_page"){
        				scope.$emit('goNext',"/");
        			}else if(type == "case_src_lib"){
        				scope.$emit('goNext',"/caseSrcLib/1");
        			}else if(type == "loan"){
        				scope.$emit('goNext','/realRiskInvest');
        			}else if(type == "mine"){
        				if(transData.sessionId != "" && transData.mobileNo != ""){
        					if(transData.userType === '1' ){
        						scope.$emit('goNext',"/mineLs");
        					}else{
        						scope.$emit('goNext',"/minePt");
        					}
        				}else{
        					scope.$emit('goNext',"/mine");
        				}
        			}
        		}
        		
        		// 监控指令元素 menuType 属性
                scope.$watch('menuType', function(newValue,oldValue, scope) {
                	if(scope.menuType == 'home_page'){
                		changeMenuShow('home_page');
        			}else if(scope.menuType == 'case_src_lib'){
        				changeMenuShow('case_src_lib');
        			}else if(scope.menuType == 'loan'){
        				changeMenuShow('loan');
        			}else if(scope.menuType == 'mine'){
        				changeMenuShow('mine');
        			}
                });
        		
        		 //根据不同的类型显示不同的menu属性
                function changeMenuShow(type){
                	list.forEach(function(value, index) {
     	    		   if(value.type == type){
     	    			   value.isSlt = true;
     	    		   }else{
     	    			   value.isSlt = false;
     	    		   }
     	           });
                   scope.menuList = list;
                }
        		
        	}
        };
    }])
    ;
});